home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / git-4.3 / git-4 / git-4.3.11 / src / gitaction < prev    next >
Encoding:
Text File  |  1996-06-06  |  5.7 KB  |  217 lines

  1. #!/bin/sh
  2.  
  3. ###############################################################################
  4. ###                                        ###
  5. ###          GNU Interactive Tools 4.3.11 per file type action script        ###
  6. ###                   Global version                ###
  7. ###        Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.   ###
  8. ###            Written by Tudor Hulubei and Andrei Pitis.            ###
  9. ###              Enhanced by Verdoolaege Sven.                    ###
  10. ###                                        ###
  11. ###############################################################################
  12.  
  13. ###
  14. ### This script executes a different action for each file type specified.
  15. ### It tries to match the second parameter against the patterns
  16. ### specified in the 'case' statement (see below).
  17. ###
  18. ### If you want to add new file types & actions to this script, just add a
  19. ### new entry to the 'case' statement *before* the last one ( *) ... )
  20. ###
  21. ### For grater flexibility, gitaction's first parameter is the name of the
  22. ### directory where the file resides. So, you can get the complete file
  23. ### name appending the file base name to the file path just like that: $1/$2
  24. ###
  25. ### If you enhance this script, please send me a patch at tudorh@pub.ro.
  26. ### I'll include it in the next release.
  27. ###
  28.  
  29. ###
  30. ### The original patch sent by Verdoolaege Sven had 'less' instead of more.
  31. ### I don't know if all Unix systems have 'less', but I am pretty sure they
  32. ### have 'more', so I've put 'more' back, for the sake of portability.
  33. ### If I am wrong, please email me.  Anyway, if you really want 'less', feel
  34. ### free to change :-)
  35. ###
  36. ### NEWS !!!
  37. ###   Instead of hardcoding "more" or "less" here, we can now use GIT_PAGER, a
  38. ### shell environment variable that binds on one of them, depending on your
  39. ### environment.  The default is to call "more", but if you change your
  40. ### GIT_PAGER environment variable, you will hopefully use "less" or any pager
  41. ### you like.
  42. ###
  43.  
  44. ###
  45. ### Thanks to John Stump for suggesting me to get rid of gitmatch.
  46. ###
  47.  
  48. name=`basename "$0"`
  49.  
  50. if test "$#" -ne 2 -o ! -d "$1" -o ! -f "$2"; then
  51.     echo "$name: GIT internal script" >&2
  52.     exit 1
  53. fi
  54.  
  55. done=0
  56.  
  57. if test -f .gitaction; then
  58.     ./.gitaction "$1" "$2"
  59.     done=$?
  60. fi
  61.  
  62. if test $done -ne 0; then
  63.     exit 0
  64. fi
  65.  
  66.  
  67. msg="Press ENTER to continue"
  68.  
  69.  
  70. case "$2" in
  71.  
  72. *.[oO])         objdump --syms --all-headers "$2" | $GIT_PAGER;        \
  73.         echo $msg; read key;;
  74. *.a | *.sa)    ar -tv "$2" | $GIT_PAGER;                \
  75.         echo $msg; read key;;
  76. *.tar)        tar tvf "$2" | $GIT_PAGER;                \
  77.         echo $msg; read key;;
  78. *.tar.gz |\
  79. *.t[arg]z |\
  80. *.tar.[zZ])    (echo "Compressed file info:";                \
  81.         gunzip -l "$2";                        \
  82.         echo;                            \
  83.         echo "Tar file info:";                    \
  84.         gunzip -c "$2" | tar tvf - ) | $GIT_PAGER;        \
  85.         echo $msg; read key;;
  86. *.man)        nroff -man "$2" | $GIT_PAGER;                \
  87.         echo $msg; read key;;
  88. *.html |\
  89. *.htm)        lynx "$2";;
  90. utmp)        w | $GIT_PAGER;                        \
  91.         echo $msg; read key;;
  92. wtmp)        last | $GIT_PAGER;                    \
  93.         echo $msg; read key;;
  94. pubring.pgp |\
  95. secring.pgp)    pgp -kv "$2" | $GIT_PAGER;                \
  96.         echo $msg; read key;;
  97. *.fig | *.FIG)    if test $DISPLAY; then                    \
  98.             (xfig "$2" > /dev/null 2>&1 &);            \
  99.         else                            \
  100.             $GIT_PAGER "$2";                \
  101.             echo $msg; read key;                \
  102.         fi;;
  103. *.gif  | *.GIF  |\
  104. *.jpg  | *.JPG  |\
  105. *.jpeg | *.JPEG |\
  106. *.tga  | *.TGA  |\
  107. *.bmp  | *.BMP  |\
  108. *.ppm  | *.PPM  |\
  109. *.pgm  | *.PGM  |\
  110. *.pbm  | *.PBM)    if test $DISPLAY; then                    \
  111.             (xv "$2" > /dev/null 2>&1 &);            \
  112.         else                            \
  113.             zgv "$2";                    \
  114.         fi;;
  115. *.tif | *.TIF |\
  116. *.xbm | *.XBM |\
  117. *.xpm | *.XPM |\
  118. *.ras | *.RAS |\
  119. *.rgb | *.RGB |\
  120. *.fts | *.FTS |\
  121. *.pm  | *.PM)   if test $DISPLAY; then                    \
  122.             (xv "$2" > /dev/null 2>&1 &);            \
  123.         else                            \
  124.             $GIT_PAGER "$2";                \
  125.             echo $msg; read key;                \
  126.         fi;;
  127. *.mpeg | *.MPEG |\
  128. *.mpg  | *.MPG) if test $DISPLAY; then                    \
  129.             (mpeg_play "$2" > /dev/null 2>&1 &);        \
  130.         else                            \
  131.             mpeg_vga "$2";                    \
  132.         fi;;
  133. *.mpg.gz    |\
  134. *.MPG.gz    |\
  135. *.mpg.[zZ]  |\
  136. *.MPG.[zZ]  |\
  137. *.mpeg.gz   |\
  138. *.MPEG.gz   |\
  139. *.mpeg.[zZ] |\
  140. *.MPEG.[zZ])    if test $DISPLAY; then                    \
  141.             (gunzip -c "$2" | mpeg_play > /dev/null 2>&1 &);\
  142.         else                            \
  143.             gunzip -c "$2" | mpeg_vga;            \
  144.         fi;;
  145. *.fli | *.FLI |\
  146. *.flc | *.FLC)    if test $DISPLAY; then                    \
  147.             (xanim "$2" > /dev/null 2>&1 &);        \
  148.         else                            \
  149.             flip "$2";                    \
  150.         fi;;
  151. *.fli.gz   |\
  152. *.FLI.gz   |\
  153. *.fli.[zZ] |\
  154. *.FLI.[zZ] |\
  155. *.flc.gz   |\
  156. *.FLC.gz   |\
  157. *.flc.[zZ] |\
  158. *.FLC.[zZ])    if test $DISPLAY; then                    \
  159.             (gunzip -c "$2" | xanim > /dev/null 2>&1 &);    \
  160.         else                            \
  161.             gunzip -c "$2" | flip -;
  162.         fi;;
  163. *.gl | *.GL)    if test $DISPLAY; then                    \
  164.             (xgrasp "$2" > /dev/null 2>&1 &);        \
  165.         else                            \
  166.             $GIT_PAGER "$2";                \
  167.             echo $msg; read key;                \
  168.         fi;;
  169. *.gl.gz   |\
  170. *.GL.gz   |\
  171. *.gl.[zZ] |\
  172. *.GL.[zZ])    if test $DISPLAY; then                    \
  173.             (gunzip -c "$2" | xgrasp > /dev/null 2>&1 &);    \
  174.         else                            \
  175.             $GIT_PAGER "$2";                \
  176.             echo $msg; read key;                \
  177.         fi;;
  178. *.mod | *.s3m)    (s3mod "$2" &);;
  179. *.voc | *.wav)    (vplay "$2" &);;
  180. *.ps | *.PS)    if test $DISPLAY; then                    \
  181.             (ghostview "$2" > /dev/null 2>&1 &);        \
  182.         else                            \
  183.         gs -sDEVICE=linux "$2";                    \
  184.         fi;;
  185. *.dvi | *.DVI)    if test $DISPLAY; then                    \
  186.             (xdvi "$2" > /dev/null 2>&1 &);            \
  187.         else                            \
  188.             $GIT_PAGER "$2";                \
  189.             echo $msg; read key;                \
  190.         fi;;
  191. *.[1-9n] |\
  192. *.[1-9n][xXm])    nroff -man "$2" | $GIT_PAGER;                \
  193.         echo $msg; read key;;
  194. *.[1-9n][xXm].gz   |\
  195. *.[1-9n][xXm].[zZ] |\
  196. *.[1-9n].gz        |\
  197. *.[1-9n].[zZ])    gunzip -c "$2" | nroff -man | $GIT_PAGER;        \
  198.         echo $msg; read key;;
  199. RMAIL)        emacs -f rmail;;
  200. *.gz  | *.GZ |\
  201. *.[zZ])        gunzip -c "$2" | $GIT_PAGER;                \
  202.         echo $msg; read key;;
  203. *.zip | *.ZIP)    unzip -v "$2" | $GIT_PAGER;                \
  204.         echo $msg; read key;;
  205. *.arj | *.ARJ |\
  206. *.a[0-9][1-9] |\
  207. *.A[0-9][1-9])    unarj l "$2" | $GIT_PAGER;                \
  208.         echo $msg; read key;;
  209. *.rar | *.RAR)    unrar l "$2" | $GIT_PAGER;                \
  210.         echo $msg; read key;;
  211. *)        $GIT_PAGER "$2";                    \
  212.         echo $msg; read key;;
  213.  
  214. esac
  215.  
  216. exit 0
  217.